local skynet = require 'skynet'
require 'skynet.manager'

require 'nggs.base.const'

skynet.error('test2 started')

skynet.start(
    function()
        skynet.timeout(
            300,
            function()
                skynet.error('test2 end')
                skynet.sleep(0)
                skynet.abort()
            end
        )

        local tbl = {
            {
                ID = 1,
                CD = 1,
                HighPriority = false
            },
            {
                ID = 2,
                CD = 2,
                HighPriority = true
            },
            {
                ID = 3,
                CD = 3,
                HighPriority = false
            }
        }

        table.sort(
            tbl,
            function(a, b)
                if a.HighPriority and not b.HighPriority then
                    return true
                elseif not a.HighPriority and b.HighPriority then
                    return false
                end
                return a.CD > b.CD
            end
        )

        for _, v in pairs(tbl) do
            print(v.ID)
        end

        -- for i = 1, 1 do
        --     print(i)
        -- end
    end
)
